<?php

namespace App\Web\Model;

use App\Web\Data;

class Model_Scrum {
    function __construct() {
    }

    /**
     * 获取冲刺信息
     *
     * @return array
     */
    function getSprintsInfoBySid($sid) {
        $ret = (new Data\Data_ScrumSprint())->getSprintsInfoBySid($sid);

        return $ret;
    }

    /**
     * 获取最近冲刺信息
     *
     * @return array
     */
    function getLastSprintInfo() {
        $ret = (new Data\Data_ScrumSprint())->getLastSprintInfo();

        return $ret;
    }

    /**
     * 获取冲刺列表
     *
     * @return array
     */
    public function getSprintsList() {
        $ret = (new Data\Data_ScrumSprint())->getSprintsList();

        return $ret;
    }

    /**
     * 获取任务列表
     *
     * @param   int $status 状态
     * @param   int $sid    冲刺id
     * @return  array
     */
    public function getTasksByStatus($status = 0, $sid = 0) {
        $ret = (new Data\Data_ScrumTasks())->getTasksByStatus($status, $sid);

        return $ret;
    }


    /**
     * 获取任务数量
     *
     * @param   int $status 状态
     * @param   int $sid    冲刺id
     * @return  array
     */
    public function getTasksNumByStatus($status = 0, $sid = 0) {
        $ret = (new Data\Data_ScrumTasks())->getTasksNumByStatus($status, $sid);

        return $ret;
    }

    /**
     * 添加冲刺
     *
     * @return array
     */
    public function addSprint($data) {
        $ret = (new Data\Data_ScrumSprint())->addRow($data);

        return $ret;
    }


    /**
     * 修改冲刺
     *
     * @date   2018-08-01
     * @param array $where
     * @param array $data
     * @return array
     */
    public function editSprint($where, $data) {
        $ret = (new Data\Data_ScrumSprint())->editRowById($where, $data);

        return $ret;
    }

    /**
     * 删除冲刺
     *
     * @date   2018-08-01
     * @param array $where
     * @return bool
     */
    public function delSprint($where) {
        $ret = (new Data\Data_ScrumSprint())->delRowById($where);

        return $ret;
    }

    /**
     * 添加任务
     *
     * @return array
     */
    public function addTask($data) {
        $ret = (new Data\Data_ScrumTasks())->addRow($data);

        return $ret;
    }

    /**
     * 修改任务
     *
     * @date   2018-08-01
     * @param array $where
     * @param array $data
     * @return array
     */
    public function editTask($taskId, $data) {
        $where = [
            [
                'filed' => 'id',
                'data'  => $taskId,
            ],
        ];
        $ret   = (new Data\Data_ScrumTasks())->editRowById($where, $data);

        return $ret;
    }

    /**
     * 删除任务
     *
     * @date   2018-08-01
     * @param array $where
     * @return bool
     */
    public function delTask($where) {
        $ret = (new Data\Data_ScrumTasks())->delRowById($where);

        return $ret;
    }

    /**
     * 任务信息
     *
     * @date   2018-08-01
     * @param int $taksId
     * @return bool
     */
    function getTaskInfoBySid($taksId) {
        $ret = (new Data\Data_ScrumTasks())->getTaskInfoById($taksId);

        return $ret;
    }
}